class Solution {
public:
    vector<vector<int>> permuteUnique(vector<int>& nums) {
        int n = nums.size();
        sort(nums.begin(),nums.end());
        // map<int,int> mm;
        // for(int i : nums) mm[i]++;
        vector<vector<int>> ret;
        vector<int> tmp(n,9);
        auto dfs = [&](auto fun,int pos, int begin,vector<int>& ans){
            // cout << pos << ' ' <<  begin << ' ' << endl;
            if(pos >= n){
                // for(int i = 0;i < n;i++){
                //     cout << ans[i] << ' ';
                // }
                // cout << endl;
                ret.push_back(ans);
                return;
            }

            if(pos != 0 && nums[pos] !=nums[pos - 1]){
                // 没有重复或者第一个不用考虑先后顺序
                begin = 0;
            }
            if(begin > n){
                return;
            } 
            for(int i = begin;i < n;i++){
                if(ans[i] == 9){
                    ans[i] = nums[pos];
                    fun(fun,pos + 1,i + 1,ans);
                    ans[i] = 9;
                }
            }
        };
        dfs(dfs,0,0,tmp);

        return ret;
    }
};


class Solution {
public:
    int maxArea(vector<int>& height) {
        int n = height.size();
        int pos = 0;
        int left = 0, right = n - 1, ans = 0;
        while (left < right) {
            ans = max(ans, (right - left) * (min(height[left], height[right])));
            if (height[left] > height[right]) {
                right--;
            } else {
                left++;
            }
        }
        return ans;
    }
};